
#include<iostream>
#include<regex>

using namespace std;

int main(){
    // string str = "Hello 2018, Bye 2017";
    string str = "1a 22b 3 4c5 dddd";
    smatch result;
    // regex pattern("\\d{4}");	//匹配四个数字
    regex pattern("\\d{1,}");

    //迭代器声明
    string::const_iterator iterStart = str.begin();
    string::const_iterator iterEnd = str.end();
    string temp;
    while (regex_search(iterStart, iterEnd, result, pattern))
    {
        temp = result[0];
        cout << temp << " ";
        iterStart = result[0].second;	//更新搜索起始位置,搜索剩下的字符串
    }

    return 0;
}


